Skip to content

refactor: Rename algo to algorithm in page_rank(), feedback_arc_set() and feedback_vertex_set() - #2859

Merged
schochastics merged 17 commits into
mainfrom
claude/issue-2788-subagents-faw1t1
Dec 3, 2026
Merged

schochastics merged 17 commits into
mainfrom
claude/issue-2788-subagents-faw1t1

Conversation

@krlmlr

@krlmlr krlmlr commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2788 (PR 1 of the stack, least controversial first); implements the algo → algorithm leg of #526.

What this does

  • Renames the algo argument to algorithm in page_rank(), feedback_arc_set() and feedback_vertex_set() — the three functions the Comprehensive plan: argument renames for 3.0.0 #2788 survey lists under the algo spelling. All three already carry their 3.0.0 keyword-only migration entries with algo after ..., so the rename is a pure registry change (algo = algorithm bare-symbol rename in tools/migrations/), and legacy algo = callers are recovered with the same single soft-deprecation as positional callers:

    Calling `page_rank()` with positional or abbreviated arguments was deprecated in igraph 3.0.0.
    i Detected call: page_rank(graph, algo)
    i Use instead: page_rank(graph, algorithm = )
    
  • Abbreviations that could mean either spelling (a, al, alg) are rejected as ambiguous by the regenerated ARG_HANDLE guards.

  • The deprecated page.rank() wrapper keeps its frozen algo formal (now documented locally with a deprecated badge, since @inheritParams page_rank no longer carries it) and forwards to algorithm.

  • Tests: named uses updated, plus new coverage that the legacy name is recovered (snapshot for page_rank(algo = ), expect_deprecated for the two feedback functions).

Since the stack was opened, main has been merged in, the migration blocks have been regenerated, and the deprecation snapshots now go through expect_snapshot_igraph() (the package-name normalization from #2938).

Generator support for head renames

This PR also extends tools/generate-migrations.R so that renames of head arguments (those before ...) are generated from the registry instead of being written by hand in each function. The later PRs of the stack use it.

  • An entry is a head rename where slot i of old has a different name from slot i of new's head. The old name stays in new as a trailing deprecated() formal, so positional calls are unchanged and silent.
  • When a call names an old argument, the generated block matches the whole call again against the pre-3.0.0 signature and binds each value to its new name. Positional values after the renamed argument keep their old meaning: set_vertex_attr(g, "x", index = i, v) still gives v to value. A hand-written bridge cannot do that (it put v into vertices), and three reverse dependencies (CurricularComplexity, martini, miloR) broke on that pattern in a revdep run of the stack.
  • Each old name gets its own soft-deprecation. A value supplied under both names, or a value that the old signature would also bind by position, is an error.
  • Entries may have no ... (rename only). passthrough_dots = TRUE marks functions that pass ... on (fit_power_law(), local_scan()); there, named arguments the old signature did not know are left to .... Replacement functions such as `vertex_attr<-` can be registered.
  • New fixtures in R/migration-fixture.R, with tests in test-migration-fixture.R and test-generate-migrations.R, cover each case. tools/migrations/README.md documents them.

Functions without a registry entry keep their hand-written bridges, 35 across the stack.

Out of scope

method (12 algorithm-choice + 2 comparison-metric functions), implementation (2) and impl (1) are the open "algorithm family" question of #2788, now tracked in #2932, and are not touched here.

The #2788 stack

Each PR is based on the previous one and merges in this order:

  1. refactor: Rename algo to algorithm in page_rank(), feedback_arc_set() and feedback_vertex_set() #2859: algo → algorithm ← this PR
  2. refactor: Rename nodes to n in generators and centr_*_tmax() #2860: nodes → n (vertex counts)
  3. refactor: snake_case weights arguments in clique functions and cluster_infomap() #2861: weights arguments
  4. refactor: Rename normalization flags to normalized #2862: normalization flags → normalized
  5. refactor: Purge legacy alias formals via the migration registry #2863: hand-rolled alias formals into the registry
  6. refactor: Rename vertex-selector arguments to vertices and vertex #2864: selectors → vertices/vertex
  7. refactor: Rename edge-selector arguments to edges #2943: edge selectors → edges
  8. refactor: Rename index to vertices/edges in the attribute accessors #2944: attribute accessors: index → vertices/edges
  9. refactor: Rename iteration arguments to n_iter/max_iter #2945: iterations → n_iter/max_iter
  10. refactor: snake_case the dotted arguments of the graph generators and degree-sequence functions #2946: snake_case: generators and degree sequences
  11. refactor: snake_case the dotted arguments of the layout functions #2947: snake_case: layouts
  12. refactor: snake_case the dotted arguments of the community, HRG, motif and graphlet functions #2948: snake_case: community, HRG, motifs, graphlets (Mu → mu)
  13. refactor: snake_case the dotted arguments of the structural and conversion functions #2950: snake_case: structural and conversion functions
  14. refactor: Rename algorithm-selection arguments to algorithm and measure selection to measure #2951: algorithm family → algorithm/measure (closes Algorithm-selection argument names: census of method/algorithm/algo/impl/implementation #2932)

🤖 Generated with Claude Code

https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 12230f8 is merged into main:

  • ✔️as_adjacency_matrix: 761ms -> 762ms [-0.87%, +1.09%]
  • ✔️as_biadjacency_matrix: 769ms -> 768ms [-0.88%, +0.6%]
  • ✔️as_data_frame_both: 1.89ms -> 1.88ms [-1.95%, +1.01%]
  • ✔️as_long_data_frame: 4.75ms -> 4.77ms [-1.01%, +1.74%]
  • ✔️es_attr_filter: 3.31ms -> 3.33ms [-0.66%, +1.89%]
  • ✔️graph_from_adjacency_matrix: 120ms -> 121ms [-0.68%, +0.98%]
  • ✔️graph_from_data_frame: 4.08ms -> 4.06ms [-1.88%, +0.79%]
  • ❗🐌vs_attr_filter: 1.76ms -> 1.79ms [+0.2%, +2.85%]
  • ✔️vs_by_name: 1.14ms -> 1.16ms [-2.05%, +4.46%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

@schochastics

Copy link
Copy Markdown
Contributor

Reviewed the rename itself and it looks correct: no drift in the generated blocks, no stale algo = callers left apart from the *_impl() C wrappers (which rightly keep it), and page.rank() forwards algorithm = algo by exact name so it doesn't double-warn.

I did find one regression in the generated ambiguity guard, fixed in 47d1fa6.

The bug

ambiguous_tags() in tools/generate-migrations.R charmatch()ed a candidate prefix against match_names — the union of renamed-away old names and new tail names. For a rename whose old name is a prefix of the new one (algo → algorithm), alg matches both entries, so charmatch() returned 0 and the tag was emitted into the guard. But both candidates resolve to the same argument, so nothing was actually ambiguous:

page_rank(g, alg = "arpack")       # soft deprecation before, hard error after
feedback_arc_set(g, alg = "exact_ip")  # newly guarded by this PR

The error message was also factually wrong ("matches multiple arguments of page_rank()"), and it contradicted tools/migrations/README.md. This isn't specific to these three functions — every rename in the #2788 stack where the old name prefixes the new one would hit it.

The fix

A prefix is ambiguous only when the names it matches resolve to different targets, so the predicate now dedupes on match_to:

hits <- startsWith(names, p)
length(unique(entry$match_to[hits])) > 1L

Regenerating narrows or drops four guards, and keeps the ones that matter:

  • page_rank(): c("a", "al", "alg", "d") → c("d"). d is genuinely ambiguous (damping vs directed) and still errors; alg = recovers under the deprecation.
  • feedback_arc_set() / feedback_vertex_set(): guard gone — it only ever held the false algo/algorithm prefixes.
  • migration_fixture(): guard gone too. It was flagging w…weigh for exactly the same reason (weight → weights), so this was a pre-existing false positive in the fixture, unrelated to the rename.
  • migration_fixture_shadow(): still rejects at =, the one case where the two candidates really do have distinct targets (weights vs the retained deprecated attr).

Test changes

  • weig = moves from the error-message snapshots to the deprecation snapshots in test-migration-fixture.R.
  • New generator-level test for ambiguous_tags(): a prefix-rename yields no tags, two distinct targets still yield "d".
  • test-centrality.R gains page_rank(star, alg = "prpack") (recovers) and page_rank(star, d = 0.5) (still errors), so the distinction is pinned at the function level.
  • Comments in generate-migrations.R and tools/migrations/fixture.R updated to state the rule correctly.

Full suite green locally: 9311 pass, 0 fail.

I kept this in the same PR rather than splitting it: the bug only becomes user-visible through this rename, and the fix changes these three functions' generated blocks, so a separate PR would leave this one mergeable-but-broken and need a rebase on the generated code anyway.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 47d1fa6 is merged into main:

  • ✔️as_adjacency_matrix: 806ms -> 804ms [-1.45%, +0.87%]
  • ✔️as_biadjacency_matrix: 801ms -> 794ms [-1.82%, +0.09%]
  • ✔️as_data_frame_both: 1.73ms -> 1.75ms [-0.79%, +2.75%]
  • ✔️as_long_data_frame: 4.18ms -> 4.19ms [-1.68%, +2.04%]
  • ✔️es_attr_filter: 2.85ms -> 2.8ms [-3.43%, +0.13%]
  • ✔️graph_from_adjacency_matrix: 143ms -> 143ms [-0.5%, +1.44%]
  • ✔️graph_from_data_frame: 3.9ms -> 3.9ms [-1.28%, +1.4%]
  • ✔️vs_attr_filter: 1.59ms -> 1.58ms [-1.7%, +1.37%]
  • ✔️vs_by_name: 1.06ms -> 1.07ms [-1.92%, +4.26%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

Comment thread R/centrality.R
@@ -42,7 +44,7 @@ page.rank <- function(
lifecycle::deprecate_warn("2.0.0", "page.rank()", "page_rank()")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will we get rid of those functions? Could we try deprecate_stop() in a PR? They're dead weight we're carrying around.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do a separate PR that removes those wrappers for good :)

Comment thread R/centrality.R Resolved
Comment thread tests/testthat/_snaps/centrality.md Outdated
Condition
Warning:
Calling `page_rank()` with positional or abbreviated arguments was deprecated in igraph 3.0.0.
i Detected call: page_rank(graph, algo)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
i Detected call: page_rank(graph, algo)
i Detected call: page_rank(graph, algo = )

I wish this looked like this so that the two lines might have real parallelism.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

algo = in the given case, but algo if called with a positional argument?

Comment thread tests/testthat/test-migration-fixture.R Outdated
})

test_that("ambiguous_tags() only flags prefixes with distinct targets", {
generator <- testthat::test_path("..", "..", "tools", "generate-migrations.R")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
generator <- testthat::test_path("..", "..", "tools", "generate-migrations.R")
generator <- test_path("..", "..", "tools", "generate-migrations.R")

Comment thread tests/testthat/test-migration-fixture.R Outdated
generator <- testthat::test_path("..", "..", "tools", "generate-migrations.R")
skip_if_not(file.exists(generator))
gen_env <- new.env()
sys.source(generator, envir = gen_env)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have something simpler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side notes: tools/ is special, this is what is available to the ./configure scripts.

Did we move the generator from R/ in the past? Why? If we test it, it could well be a file in R/ and rbuildignore-d (alongside the test file).

claude and others added 2 commits September 10, 2026 11:03
…c_set()` and `feedback_vertex_set()` (#2788, #526)

The legacy `algo` spelling is recovered by the generated ARG_HANDLE blocks
and soft-deprecated;
abbreviations of both spellings are guarded as ambiguous.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR
`ambiguous_tags()` charmatched a candidate prefix against `match_names`,
so any rename whose old name is a prefix of the new one (`algo` ->
`algorithm`) flagged `a`, `al` and `alg` as ambiguous even though both
candidates resolve to the same argument. Those calls used to work with a
soft deprecation and hard-errored instead, with a message that was
factually wrong.

Dedupe on `match_to` so a prefix is ambiguous only when the names it
matches resolve to different arguments of the new API. Regenerating
narrows the `page_rank()` guard to `d` (`damping` vs `directed`, a real
ambiguity), drops the guards from `feedback_arc_set()` and
`feedback_vertex_set()` entirely, and also drops the same latent false
positive from `migration_fixture()` (`weight` -> `weights`).
`migration_fixture_shadow()` keeps rejecting `at =`, where the two
candidates really do have distinct targets.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@krlmlr
krlmlr force-pushed the claude/issue-2788-subagents-faw1t1 branch from 47d1fa6 to d010bfd Compare September 10, 2026 09:03
@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if d010bfd is merged into main:

  • ✔️as_adjacency_matrix: 232ms -> 233ms [-1.68%, +2.68%]
  • ✔️as_biadjacency_matrix: 244ms -> 243ms [-3.6%, +2.77%]
  • ✔️as_data_frame_both: 222ms -> 221ms [-2.43%, +2.19%]
  • ✔️as_long_data_frame: 182ms -> 181ms [-2.25%, +1.07%]
  • ✔️es_attr_filter: 227ms -> 229ms [-1.32%, +3.17%]
  • ✔️graph_from_adjacency_matrix: 277ms -> 273ms [-3.3%, +0.98%]
  • ✔️graph_from_data_frame: 239ms -> 239ms [-1.69%, +1.83%]
  • ✔️vs_attr_filter: 237ms -> 236ms [-2.56%, +1.87%]
  • ✔️vs_by_name: 211ms -> 211ms [-3.8%, +3%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

@maelle

maelle commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

schochastics and others added 2 commits October 15, 2026 21:06
…agents-faw1t1

# Conflicts:
#	tests/testthat/test-migration-fixture.R
… after merging main

Part of #2788.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if b44ae03 is merged into main:

  • 🚀E_named: 217ms -> 212ms [-3.65%, -0.84%]
  • ✔️V_named: 431ms -> 430ms [-0.72%, +0.53%]
  • ✔️all_simple_paths_named: 153ms -> 153ms [-0.46%, +1.03%]
  • ❗🐌as_adjacency_matrix: 244ms -> 246ms [+0.05%, +1.08%]
  • ✔️as_biadjacency_matrix: 261ms -> 260ms [-0.99%, +0.36%]
  • ✔️as_data_frame_both: 264ms -> 263ms [-1.07%, +0.67%]
  • ✔️as_long_data_frame: 214ms -> 215ms [-0.58%, +1.58%]
  • ✔️ego_order2_named: 158ms -> 158ms [-1.34%, +1.62%]
  • ✔️es_attr_assign: 237ms -> 236ms [-0.55%, +0.18%]
  • ✔️es_attr_filter: 245ms -> 245ms [-0.5%, +0.44%]
  • ✔️graph_from_adjacency_matrix: 279ms -> 279ms [-0.7%, +0.42%]
  • ✔️graph_from_data_frame: 286ms -> 284ms [-1.29%, +0.08%]
  • ✔️head_of_named: 178ms -> 179ms [-0.65%, +1.35%]
  • ✔️incident_edges: 210ms -> 211ms [-0.87%, +1.16%]
  • ✔️max_cliques_named: 26.2ms -> 26.3ms [-0.17%, +0.99%]
  • ✔️neighbors_by_name: 317ms -> 316ms [-0.93%, +0.55%]
  • ✔️union_named: 240ms -> 238ms [-2.64%, +0.91%]
  • ✔️vs_attr_filter: 334ms -> 334ms [-0.83%, +1.07%]
  • ✔️vs_by_name: 304ms -> 303ms [-0.46%, +0.37%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

schochastics and others added 3 commits December 2, 2026 17:38
# Conflicts:
#	R/centrality.R
#	R/structural-properties.R
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generator-level tests repeated the same lookup, skip and `sys.source()`
of tools/generate-migrations.R; `migration_generator_env()` in
helper-migrations.R now does that once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if e508e36 is merged into main:

Status Name Current Incoming Interval
✔️ V_named 360.1ms 358.6ms [-1.77%, +0.94%]
✔️ graph_from_adjacency_matrix 223.1ms 223.7ms [-0.34%, +0.84%]
✔️ graph_from_data_frame 215.5ms 215.7ms [-0.72%, +0.93%]
✔️ vs_subset_positional 194.6ms 195.6ms [-0.78%, +1.84%]
✔️ as_biadjacency_matrix 184.1ms 184.4ms [-1.43%, +1.77%]
✔️ es_attr_assign 179.8ms 180.4ms [-0.5%, +1.14%]
✔️ es_attr_filter 177.8ms 177.7ms [-1.07%, +0.94%]
✔️ as_adjacency_matrix 170.2ms 170.3ms [-0.74%, +0.84%]
✔️ vs_by_name 168.8ms 168.5ms [-0.79%, +0.42%]
✔️ E_named 169.3ms 168.2ms [-1.54%, +0.24%]
✔️ max_cliques_sizes_named 160.1ms 159.8ms [-1.09%, +0.76%]
✔️ as_data_frame_both 150.1ms 149ms [-2.39%, +0.88%]
❗🐌 as_long_data_frame 143.2ms 144.1ms [+0.19%, +1.16%]
✔️ incident_edges 138.6ms 137.8ms [-2.24%, +1.07%]
🚀 union_named 137.8ms 137ms [-1.11%, -0.08%]
✔️ vs_attr_filter 132.8ms 133.2ms [-0.27%, +0.77%]
✔️ head_of_named 120ms 119.8ms [-1.11%, +0.9%]
✔️ ego_order2_named 111.5ms 111.3ms [-0.9%, +0.53%]
✔️ neighbors_by_name 103.2ms 103ms [-0.69%, +0.44%]
✔️ all_simple_paths_named 98.6ms 98ms [-1.14%, +0.03%]
✔️ vs_by_literal_name 72.2ms 72.7ms [-0.28%, +1.55%]
✔️ degree_few_vertices 67.7ms 67.2ms [-1.71%, +0.49%]
✔️ strength_weighted_named 22.3ms 22.4ms [-0.66%, +1.21%]
✔️ max_cliques_named 19.8ms 19.8ms [-0.6%, +1.1%]

Further explanation regarding interpretation and methodology can be found in the documentation.

Last updated for commit e508e36.

schochastics and others added 7 commits December 3, 2026 07:24
# Conflicts:
#	R/centrality.R
#	R/structural-properties.R
… name

A head argument renamed in its slot keeps its old name as a `deprecated()`
formal. A call that passes that name was written against the old signature,
but base R binds its later positional values against the new one:
`set_vertex_attr(g, "x", index = i, v)` hands `v` to `vertices`. The
generator now reads such renames off the registry and emits a block that
matches the whole call against the old signature again, binds each value to
its new name lazily, and deprecates each old name, so hand-written bridges
are no longer needed. Registry entries may also omit `...` (rename-only
migrations) and name replacement functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… arguments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A registry entry with `passthrough_dots = TRUE` gets the re-match for old
head names but no recovery out of `...`, and named arguments the old
signature did not know are left to `...`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e head

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schochastics schochastics reopened this Dec 3, 2026
R CMD check requires the last formal of a replacement function to be
`value`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schochastics schochastics reopened this Dec 3, 2026
schochastics and others added 2 commits December 3, 2026 17:49
A function with both a legacy block and a `...` recovery block defined
`.old_signature()` twice with different formals, which R CMD check
reports as a NOTE. The legacy block now uses `.legacy_signature()`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schochastics schochastics reopened this Dec 3, 2026
@schochastics
schochastics merged commit b9afd4d into main Dec 3, 2026
12 checks passed
@schochastics
schochastics deleted the claude/issue-2788-subagents-faw1t1 branch December 3, 2026 20:01
schochastics pushed a commit to schochastics/rigraph that referenced this pull request Dec 4, 2026
…c_set()` and `feedback_vertex_set()` (igraph#2859)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: David Schoch <david@schochastics.net>
(cherry picked from commit b9afd4d)

R-side fix: snapshot the deprecation through expect_snapshot_igraph(), so the flavor's package name is normalized.
schochastics pushed a commit to schochastics/rigraph that referenced this pull request Dec 4, 2026
…c_set()` and `feedback_vertex_set()` (igraph#2859)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: David Schoch <david@schochastics.net>
(cherry picked from commit b9afd4d)

R-side fix: snapshot the deprecation through expect_snapshot_igraph(), so the flavor's package name is normalized.

R-side fix: air wraps the snapshot line that expect_snapshot_igraph() made too long.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Algorithm-selection argument names: census of method/algorithm/algo/impl/implementation

4 participants